import {reqCategoryList,reqBannerList,reqFloorList} from '@/api';

const state = {
    categoryList: [],
    bannerList: [],
    floorList: []
};

const getters = {};

const mutations = {
    CATEGORYLIST(state,categoryList) {
        state.categoryList = categoryList;
    },
    GETBANNERLIST(state,bannerList) {
        state.bannerList = bannerList;
    },
    GETFLOORLIST(state,floorList) {
        state.floorList = floorList;
    }
};

const actions = {
    // 获取3级分类数据
    async getCategoryList({commit}) {
        let res = await reqCategoryList();  
        if(res.code == 200) {
            commit('CATEGORYLIST',res.data);
        }
    },

    // 获取轮播图数据
    async getBannerList({commit}) {
        let res = await reqBannerList();
        if(res.code == 200) {
            commit('GETBANNERLIST',res.data);
        }
    },

    // 获取floor数据
    async getFloorList({commit}) {
        let res = await reqFloorList();
        if(res.code == 200) {
            commit('GETFLOORLIST',res.data);
        }
    }
};

export default {
    state,
    getters,
    mutations,
    actions
}